package cn.foo.service.impl;

import cn.foo.dao.UserDao;
import cn.foo.pojo.User;
import cn.foo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author Frank
 * @date 07-05
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    UserDao userDao;

    //public void setUserDao(UserDao userDao) {
    //    this.userDao = userDao;
    //}


    //public UserServiceImpl() {
    //}
    //
    //public UserServiceImpl(UserDao userDao) {
    //    this.userDao = userDao;
    //}

    @Override
    public int addNewUser(User user) {
        //添加用户的SQL
        int count = userDao.save(user);
        //添加用户地址信息SQL
        System.out.println("添加用户的地址信息失败");
        int i = 1/0;
        return count;
    }

    @Override
    public void deleteUser(int id) {
        System.out.println("删除用户");
    }


    @Override
    public List<User> findUsers() {
        return userDao.selectUsers();
    }
}
